package com.whmskj.xjlhbc.mobile.controller;

import com.whmskj.xjlhbc.core.AjaxResult;
import com.whmskj.xjlhbc.dto.ScPlanDto;
import com.whmskj.xjlhbc.service.IPlanService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/plan")
public class PlanController {

    @Autowired
    private IPlanService service;

    @Tag(name = "生产计划",description = "生产计划")
    @GetMapping("/sc")
    @Operation(description = "生产计划",parameters = @Parameter(name = "date",description = "日期,yyyy-MM"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, ScPlanDto.class})
    ))
    public AjaxResult getScPlan(@RequestParam(required = false) String date){
        ScPlanDto result = service.getScPlan(date);
        return AjaxResult.success(result);
    }

    @Tag(name = "织机计划",description = "织机计划")
    @GetMapping("/zj")
    @Operation(description = "织机计划",parameters = @Parameter(name = "date",description = "日期,yyyy-MM"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, List.class})
    ))
    public AjaxResult getZjPlan(@RequestParam(required = false) String date){
        List<Object> result = service.getZjPlan(date);
        return AjaxResult.success(result);
    }

}
